<?php
include('include/config.inc.php');
if(!isset($_SESSION['s_activId'.$cfgPack])
  || (isset($_SESSION['s_userType'.$cfgPack]) && isset($cfgFileNames['party'][$_SESSION['s_userType'.$cfgPack]]) 
      && $cfgFileNames['party'][$_SESSION['s_userType'.$cfgPack]] == 0))
{
  $_SESSION['s_urlRedirectDir'] = $_SERVER['REQUEST_URI'];
  header("Location:checkLogin.php");
}
else
{
  $newInstallDetailArray  = array();
  $newInstallCount        = 0;
  $msg = '<tr><td align="center" colspan="6"> <h2><font color="red"><b>Record Not Found...!</b></h2></font></td></tr>';

  $selectNewInstall = "SELECT newinstallationmaster.newinstallationMasterId,newinstallationmaster.installationDate,
                              DATE_FORMAT(newinstallationmaster.installationDate,'%d-%m-%Y') AS installationDate,
                              newinstallationmaster.status,party.companyName,category.categoryName,subcategory.subCategoryName,
                              item.itemName,newinstallationdetail.quantity,newinstallationdetail.description
				  						   FROM newinstallationmaster
					 						   JOIN newinstallationdetail   
					 						   JOIN party   
											   JOIN category
											   JOIN subcategory 
											   JOIN item 
											  WHERE party.partyId             = newinstallationmaster.partyId 
											    AND category.categoryId       = newinstallationdetail.categoryId  
											    AND subcategory.subCategoryId = newinstallationdetail.subCategoryId  
											    AND item.itemId               = newinstallationdetail.itemId 
											    AND newinstallationmaster.newinstallationMasterId = newinstallationdetail.newinstallationMasterId"; 
  $selectNewInstallResult = mysql_query($selectNewInstall);
  $newInstallRow = mysql_num_rows($selectNewInstallResult);
  if($newInstallRow > 0)
  {
	  while($newInstallRow = mysql_fetch_array($selectNewInstallResult))
	  {
		  $newInstallDetailArray[$newInstallCount]['newinstallationMasterId'] = $newInstallRow['newinstallationMasterId'];
	    $newInstallDetailArray[$newInstallCount]['companyName']             = $newInstallRow['companyName'];
		  $newInstallDetailArray[$newInstallCount]['categoryName']            = $newInstallRow['categoryName'];
		  $newInstallDetailArray[$newInstallCount]['subCategoryName']         = $newInstallRow['subCategoryName'];
		  $newInstallDetailArray[$newInstallCount]['itemName']                = $newInstallRow['itemName'];
		  $newInstallDetailArray[$newInstallCount]['quantity']                = $newInstallRow['quantity'];
		  $newInstallDetailArray[$newInstallCount]['installationDate']        = $newInstallRow['installationDate'];
		  $newInstallDetailArray[$newInstallCount]['description']             = $newInstallRow['description'];
		  $newInstallCount++;
	 }   
 }
 else
 {
	$msg = '<tr><td align="center" colspan="10"> <h2><font color="red"><b>Record Not Found...!</b></h2></font></td></tr>';
 }
  include("./bottom.php");
  $smarty->assign("msg",$msg);
  $smarty->assign("newInstallDetailArray",$newInstallDetailArray);
  $smarty->display("newInstallationList.tpl");
}
?>